package com.swipemaster.network.task;

import android.app.Activity;

import com.swipemaster.dialogs.Dialogs;
import com.swipemaster.network.Network;
import com.swipemaster.record.Record;

public class IsWorldRecordTask extends ProgressTask<Void, Void, Boolean>
{
	private final Record record;

	public IsWorldRecordTask(Activity activity, Record record)
	{
		super(activity);
		this.record = record;
	}

	@Override
	protected Boolean doInBackground(Void... params)
	{
		try
		{
			return Network.isWorldRecord(record);
		}
		catch (final Exception e)
		{
			e.printStackTrace();
			return null;
		}
	}

	@Override
	protected void onPostExecute(Boolean isWorldRecord)
	{
		super.onPostExecute(isWorldRecord);

		if ((isWorldRecord != null) && isWorldRecord)
		{
			Dialogs.showEntryTextDialog(activity, record.recordId);
		}
	}
}